<?php
class Apiv1_TestController extends Ctrl_Api{
    public function indexAction(){
        $p = $_REQUEST;
        
        //$tTime = strtotime(date('Y-m-d',time()));
        $tTime = time();
        
        $tRMO = new RemindModel;
        $tRPMO = new RemindplanModel;

        //查询符合当前时间五分钟前的所有提醒事件
        $tRDatas = $tRMO->field('*')->where('starttime <= '.$tTime.' and endtime >= '.($tTime+5*60*60))->fList();
        
        if(!empty($tRDatas)){
                
            foreach($tRDatas as $tRow){
                $tResponddate = strtotime(date('Y-m-d',$tTime));    

                $tData = array(
                    'r_id' => $tRow['id'],
                    'sid' => $tRow['sid'],
                    'sw_id' => $tRow['sw_id'],
                    'status' => 0,
                    'respond_date' => $tResponddate,
                    'created' => $tTime,
                );
                
                if(!$tRPMO->insert($tData)){
                    Tool_Fnc::ajaxMsg('操作失败');
                }

            }   
            Tool_Fnc::ajaxMsg('操作成功',1);     
        }
    }
}
?>
